clear 
use "C:\Users\roro\Dropbox\RoRoPeff\German Survey\Germany 2019\Papers\Manuscript\Take 4\Pol Beh Submission\Replication Files\Pol_Beh_cses5_Replication_Data.dta" 

**************************
***Create Germany dummy***
**************************
destring 		E1006,gen(country)
gen		country_DE=country 
recode		country_DE 2760=1 *=.
*keep if		country_DE==1

**************************
***Election Study Dummy***
**************************

gen			ES=E1004 // provides year of election study 
label var	ES "Year of Election Study"

label define country 0360 "Australia" 0400 "Austria" 0561 "Belgium-F" 0562 "Belgium-W" 0760 "Brazil" 1240 "Canada" 1520 "Chile" 1880 "Costa Rica" 2080 "Denmark" 2460 "Finland" 2500 "France" ///
			2760 "Germany" 8260 "Great Britain" 3000 "Greece" 3440 "Hongkong" 3480 "Hungary" 3520 "Iceland" 3720 "Ireland" 3760 "Israel" 3800 "Italy" 3920 "Japan" 4100 "Korea" 4400 "Lithuania" ///
			4990 "Montenegro" 5280 "Netherlands" 5540 "New Zealand" 5780 "Norway" 6200 "Portugal" 7030 "Slovakia" 7520 "Sweden" 7560 "Switzerland" 1580 ///
			"Taiwan" 7640 "Thailand" 7880 "Tunisia" 7920 "Turkey" 8400 "United States" 8580 "Uruguay" 
label values country country

*********************
***Create EW dummy***
*********************
gen			EW=country
recode		EW (0360 0400 0561 0562  1240 2080 2460 2500 2760 3520 8260 3000 3720 3800  5280 5540 5780 6200  7520 7560 =1) (3480 4400 7030 8030 =0) (*=.)
*tab E1008 country // country by election year:

*********************
***Create AIS dummy***
*********************
gen			AIS=country
recode		AIS (0360 0400 0561 0562  2080 2460 2500 2760 8260 3000 3520 3720 3800  5280 5780 6200  7520 7560 8400 3480 4400 7030 8030=1) (*=.)
*tab E1008 country // country by election year:

******************************
***Create populism indicator***
******************************
gen		compbad=E3004_1 //What people call compromise in politics is really just selling out on one's principles.
recode		compbad 7 8 9=.
label values compbad E3004_1 

gen		polsnocare=E3004_2 //Most politicians do not care about the people.
recode		polsnocare 7 8 9=.
label values polsnocare E3004_2

gen		polstrustworthy=E3004_3 //Most politicians are trustworthy.
recode		polstrustworthy 7 8 9=.
label values polstrustworthy E3004_3
*reverse code
gen 		polstrustworthy_r=(polstrustworthy*-1)+6
label var	polstrustworthy_r "1 SD 5 SA"

gen		polsmainproblem=E3004_4 //Politicians are the main problem in [COUNTRY]
recode		polsmainproblem 7 8 9=.
label values polsmainproblem E3004_4

gen		strongleader=E3004_5 //Having a strong leader in government is good for [COUNTRY] even if the leader bends the rules to get things done.
recode		strongleader 7 8 9=.
label values strongleader E3004_5

gen		peopledecide=E3004_6 //The people, and not politicians, should make our most important policy decisions.
recode		peopledecide 7 8 9=.
label values peopledecide E3004_6

gen		polsrich=E3004_7 //Most politicians care only about the interests of the rich and powerful.
recode		polsrich 7 8 9=.
label values polsrich E3004_7

corr compbad polsnocare polstrustworthy_r polsmainproblem strongleader peopledecide polsrich

egen		populism=rowmean(compbad polsnocare polstrustworthy_r polsmainproblem strongleader peopledecide polsrich)
label var	populism "1 Populist 5 Non-populist"
gen			populism01=(populism/5)
label var	populism01 "0 Populist 1 Non-populist"
gen			populism01rev=(populism01*-1)+1
label var	populism01rev "0 Non-populist 1 Populist"

**************************************************
***Create a past vote variable for each country***
**************************************************
gen 		vote_DE=E3013_LH_PL if country_DE==1
label 		values vote_DE E3013_LH

gen 		vote_DE_r=vote_DE
recode		vote_DE_r 276008/999999=.
label values vote_DE_r E3013_LH

*********************************
***Satisfaction with Democracy***
*********************************
gen		swd=E3023
recode		swd 1=5 2=4 8=3 4=2 5=1 6 7 9 10=.
label var	swd "1 Very Dissatisfied 5 Very satisfied"

************************************
***Create pairwise country groups***
************************************
gen			DE_AUT=country
recode		DE_AUT 2760 0400 =1 *=0
gen			DE_AUS=country
recode		DE_AUS 2760 0360 =1 *=0
gen			DE_BE_F=country
recode		DE_BE_F 2760 0561=1 *=0
gen			DE_CH=country
recode		DE_CH 2760 7560=1 *=0
gen			DE_F=country
recode 		DE_F 2760 2500=1 *=0
gen			DE_BE_W=country
recode		DE_BE_W 2760 0562=1 *=0
gen			DE_DK=country
recode		DE_DK 2760 2460 =1 *=0
gen			DE_FI=country
recode		DE_FI 2760 2460 =1 *=0
gen			DE_HU=country
recode		DE_HU 2760 3480 =1 *=0
gen			DE_ICE=country
recode		DE_ICE 2760 3520 =1 *=0
gen			DE_IRE=country // no observations because compbad is missing
recode		DE_IRE 2760 3720=1 *=0
gen			DE_IT=country
recode		DE_IT 2760 3800=1 *=0
gen			DE_LT=country
recode		DE_LT 2760 4400=1 *=0
gen			DE_NL=country
recode		DE_NL 2760 5280 =1 *=0
gen			DE_NZ=country
recode		DE_NZ 2760 5540=1 *=0
gen			DE_NOR=country
recode		DE_NOR 2760 5780=1 *=0
gen			DE_SVK=country
recode		DE_SVK 2760 7030=1 *=0
gen			DE_TR=country
recode		DE_TR 2760 7920=1 *=0
gen			DE_USA=country
recode		DE_USA 2760 8400=1 *=0
gen			DE_USA_20=DE_USA
replace		DE_USA_20 =0 if ES=="USA_2016"
gen			DE_USA_16=DE_USA
replace		DE_USA_16 =0 if ES=="USA_2020"

STOP 
**************************************************************
***Figure A4: Populism distribution in Advanced Democracies***
**************************************************************
graph bar (mean) populism01rev if AIS==1, over(country, sort(populism01rev) descending label(angle(ninety))) cw ///
				ytitle(Mean populism scores 0 Low 1 High)

				
				
				

***********************************************************************************************
***Table A5: Confirmatory factor Analyses of populism indicators: comparing Germany to other countries***
***********************************************************************************************


***********************
***Germany-Austria***
***********************
***RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_AUT==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100) 
estat gof,stats(all)
estimates store M1

* predict lat*,latent // predicts latent factor scores for each group 

***RMSEA, CFI suggest a reasonably close fit when one assumes identical loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_AUT==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estat gof,stats(all)
estimates store M2
estat mindices
lrtest M1 M2

***********************
***Germany-Australia***
***********************
***RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_AUS==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M1
estat mindices

***RMSEA, CFI suggest a reasonably close fit when one assumes identical loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_AUS==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estat gof,stats(all)
estimates store M2
estat mindices
lrtest M1 M2

***********************
***Germany-Belgium-F***
***********************
***RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_BE_F==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M1
estat mindices

***RMSEA, CFI suggest a reasonably close fit when one assumes identical loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_BE_F==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0)  ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M2
estat mindices
lrtest M1 M2


***********************
***Germany-Belgium-W***
***********************
***RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_BE_W==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M1
estat mindices

***RMSEA, CFI suggest a reasonably close fit when one assumes identical loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_BE_W==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0)  ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M2
estat mindices
lrtest M1 M2

***********************
***Germany-Denmark***
***********************
***RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_DK==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M1
estat mindices

***RMSEA, CFI suggest a reasonably close fit when one assumes identical loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_DK==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0)  ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M2
estat mindices
lrtest M1 M2


***********************
***Germany-Finland***
***********************
***RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_FI==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M1
estat mindices

***RMSEA, CFI suggest a reasonably close fit when one assumes identical loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_FI==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0)  ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M2
estat mindices
lrtest M1 M2



********************
***Germany-France***
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_F==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M1
********************

***RMSEA, CFI suggest a reasonably close fit assuming no equality constraint

estat mindices

*RMSEA, CFI suggest a reasonably close fit when one assumes identical loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_F==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estat gof,stats(all)
estimates store M2
lrtest M1 M2

*********************
***Germany-Hungary***
*********************

*RMSEA, CFI suggest a BORDERLINE fit
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_HU==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estimates store M1
estat mindices

*RMSEA, CFI suggests poor fit for identifcal loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_HU==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estat gof,stats(all)
estimates store M2
estat mindices
lrtest M1 M2

*********************
***Germany-Iceland***
*********************

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_ICE==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit when one assumes identical loadings
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_ICE==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices

lrtest M1 M2


*********************
***Germany-Ireland***
*********************
*no observations for compbad = md
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_IRE==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estat gof,stats(all)
estat mindices

*******************
***Germany-Italy***
*******************

*Germany-Italy: RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_IT==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1
estat gof,stats(all)
estat mindices

*Germany-Italy: RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_IT==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices
lrtest M1 M2


***********************
***Germany-Lithuania***
***********************

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_LT==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_LT==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices
lrtest M1 M2


*************************
***Germany-New Zealand***
*************************
*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_NZ==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1 
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_NZ==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices
lrtest M1 M2


*************************
***Germany-Netherlands***
*************************
*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_NL==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1 
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_NL==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices
lrtest M1 M2

*************************
***Germany-Norway***
*************************
*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_NOR==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1 
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_NOR==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices
lrtest M1 M2

*************************
***Germany-Slovakia***
*************************
*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_SVK==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1 
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_SVK==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices
lrtest M1 M2

*************************
***Germany-Switzerland***
*************************
*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_CH==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1 
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_CH==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices
lrtest M1 M2


*************************
***Germany-Turkey***
*************************
*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_TR==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1 
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_TR==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
estat mindices
lrtest M1 M2

**********************
***Germany-USA-2016***
**********************

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_USA_16==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_USA_16==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
*estat mindices
lrtest M1 M2

**********************
***Germany-USA-2020***
**********************

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_USA_20==1, ///
		group(country) ginvariant(none) ///
		means(Dim1@0) ///
		covstruct(_lexogenous, diagonal) latent(Dim1) variance (Dim1@1 ) standardized iterate(100)
estimates store M1
estat gof,stats(all)
estat mindices

*RMSEA, CFI suggest a reasonably close fit assuming no equality constraint
sem (compbad polsnocare polstrustworthy polsmainproblem strongleader peopledecide polsrich<- Dim1) if DE_USA_20==1, ///
		group(country) ginvariant(mcoef) ///
		means(Dim1@0) 
estimates store M2
estat gof,stats(all)
*estat mindices
lrtest M1 M2

